package com.bill.common.system.action;

import org.springframework.beans.factory.annotation.Autowired;

import com.bill.common.system.dto.BuyCreditsDTO;
import com.bill.common.system.dto.BuyCreditsQueryDTO;
import com.bill.common.system.service.IBuyCreditsService;
import com.opensymphony.xwork2.ActionSupport;
import com.sinba.common.dto.PageDTO;

@SuppressWarnings("serial")
public class BuyCreditsAction extends ActionSupport{

	@Autowired
	private IBuyCreditsService buyCreditsService;
	
	private PageDTO pageDTO = new PageDTO();
	private BuyCreditsDTO buyCreditsDTO = new BuyCreditsDTO();
	private BuyCreditsQueryDTO queryDTO = new BuyCreditsQueryDTO();
	private int page = 1;
    private int rows = 10;
    private String sidx;
    private String sord;
    private Long id;
    private String resultStr;
    private String pageUrl;
	
	
	public PageDTO getPageDTO() {
		return pageDTO;
	}



	public void setPageDTO(PageDTO pageDTO) {
		this.pageDTO = pageDTO;
	}



	public BuyCreditsDTO getBuyCreditsDTO() {
		return buyCreditsDTO;
	}



	public void setBuyCreditsDTO(BuyCreditsDTO buyCreditsDTO) {
		this.buyCreditsDTO = buyCreditsDTO;
	}



	public BuyCreditsQueryDTO getQueryDTO() {
		return queryDTO;
	}



	public void setQueryDTO(BuyCreditsQueryDTO queryDTO) {
		this.queryDTO = queryDTO;
	}



	public int getPage() {
		return page;
	}



	public void setPage(int page) {
		this.page = page;
	}



	public int getRows() {
		return rows;
	}



	public void setRows(int rows) {
		this.rows = rows;
	}



	public String getSidx() {
		return sidx;
	}



	public void setSidx(String sidx) {
		this.sidx = sidx;
	}



	public String getSord() {
		return sord;
	}



	public void setSord(String sord) {
		this.sord = sord;
	}



	public Long getId() {
		return id;
	}



	public void setId(Long id) {
		this.id = id;
	}



	public String getResultStr() {
		return resultStr;
	}



	public void setResultStr(String resultStr) {
		this.resultStr = resultStr;
	}



	public String getPageUrl() {
		return pageUrl;
	}



	public void setPageUrl(String pageUrl) {
		this.pageUrl = pageUrl;
	}



	public String findBuyCreditsPager(){
		int start = ( page - 1 ) * rows;
		queryDTO.setStart(start);
		queryDTO.setLimit(rows);
        pageDTO = buyCreditsService.findBuyCreditsPager(queryDTO, sord, sidx);
        pageDTO.setPage( page );
        pageDTO.setRows( rows );
		return SUCCESS;
	}
	
	public String creditsOpt(){
		if ( ( pageUrl == null ) || ( pageUrl == "" ) ){
            pageUrl = "index.jsp";
        }
		resultStr = buyCreditsService.creditsOpt(buyCreditsDTO);
		if("confirmBackHesk".equals(buyCreditsDTO.getOptType())){
			return "resultStr";
		}
		return "optresult";
	}
	
	
}
